home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / MacCalendar 1.0d5 / Src / MacCalendarSetup.r < prev    next >
Encoding:
Text File  |  1994-06-30  |  14.4 KB  |  560 lines  |  [TEXT/KAHL]

  1. /*                                    MacCalendarSetup.r                                */
  2. /*
  3.  * MacCalendarSetup.r
  4.  * Copyright © 1994 Martin Minow. All rights reserved.
  5.  */
  6. #define REZ
  7. #define  SystemSevenOrLater 1
  8. #include "Pict.r"
  9. #include "Types.r"
  10. #include "SysTypes.r"
  11. #include "BalloonTypes.r"
  12. #include "MacCalendarSetup.h"
  13. #if MPW
  14. include "::MacCalendarSetupIcons.rsrc";
  15. #endif
  16.  
  17. /*
  18.  * Boilerplate
  19.  */
  20.  
  21. resource 'vers' (1) {
  22.     kVersionMajor, kVersionMinor, kVersionStage, kVersionRelease, verUS,
  23.     kVersionIdent,
  24.     kVersionString
  25. };
  26.  
  27. type kSetupAppCreator as 'STR ';
  28.  
  29. resource kSetupAppCreator (0) {
  30.     "MacCalendarSetup: " kVersionString
  31. };
  32. resource 'BNDL' (BNDL_SetupApp) {
  33.     kSetupAppCreator, 0,
  34.     {
  35.         'FREF', {0, FREF_SetupApp};
  36.         'ICN#', {0, ICON_SetupApp};
  37.     }
  38. };
  39.  
  40. resource 'FREF' (FREF_SetupApp) {
  41.     'APPL', 0, ""
  42. };
  43.  
  44. /*
  45.  * This should match the definition in MacCalendar.r
  46.  */
  47. resource 'STR#' (STRN_Info) {
  48.     {
  49.         "MacCalendar Preferences",
  50.         "MacCalendar\n\n"
  51.             "This Control Strip module displays the current month’s calendar",
  52.         "Helvetica",                        /* Font name                    */
  53.         "14",                                /* Font size                    */
  54.         "1",                                /* 1 == Sunday, 2 == Monday        */
  55.         "\001S\001M\002Tu\001W\002Th\001F\001S\000",    /* Day name string    */
  56.     }
  57. };
  58.  
  59. resource 'DLOG' (DLOG_Setup, "Setup Dialog", purgeable) {
  60.         {  0 + 30, 0 + 30, 320 + 30, 290 + 30 },
  61.         dBoxProc,
  62.         invisible,
  63.         noGoAway,
  64.         0,
  65.         DLOG_Setup,
  66.         "",
  67. #if SystemSevenOrLater
  68.         alertPositionMainScreen
  69. #endif
  70. };
  71.  
  72. resource 'DITL' (DLOG_Setup, "Setup Dialog", preload, purgeable) {
  73.     {
  74.         { 290, 200, 310, 280 },    Button        { enabled, "OK"                        },
  75.         { 290,   4, 310,  80 },    Button        { enabled, "Cancel"                    },
  76.         {   4,   4, 176, 286 }, UserItem    { disabled /* Sample calendar */    },
  77. #define kFontPopupRect        { 230,  10, 250, 160 }
  78.         kFontPopupRect,            Control        { enabled, CNTL_FontPopup            },
  79. #define kFontSizePopupRect    { 230, 170, 250, 280 }
  80.         kFontSizePopupRect,        Control        { enabled, CNTL_SizePopup            },
  81. #define kFirstDayPopupRect    { 260,  10, 280, 280 }
  82.         kFirstDayPopupRect,        Control        { enabled, CNTL_FirstDayPopup        }, 
  83.         { 180,  10, 196, 282 }, UserItem    { disabled, /* Day labels */        },
  84.         { 200,    10, 216,  42 },    EditText    { enabled,    "Su"                    },
  85.         { 200,    50, 216,  82 },    EditText    { enabled,    "M"                        },
  86.         { 200,    90, 216, 122 },    EditText    { enabled,    "Tu"                    },
  87.         { 200, 130, 216, 162 },    EditText    { enabled,    "W"                        },
  88.         { 200, 170, 216, 202 },    EditText    { enabled,    "Th"                    },
  89.         { 200, 210, 216, 242 },    EditText    { enabled,    "F"                        },
  90.         { 200, 250, 216, 282 },    EditText    { enabled,    "Sa"                    },
  91. #if DEBUG
  92.         /*
  93.          * This lets us test the drawing algorithm without rebuilding the
  94.          * actual status bar and rebooting the machine.
  95.          */
  96.         { 290,  88, 310, 133 },    Button        { enabled, "Prev"                    },
  97.         { 290, 143, 310, 188 },    Button        { enabled, "Next"                    },
  98. #endif
  99.         {  0,   0,   0,   0}, HelpItem        { disabled, HMScanhdlg { HELP_Setup }},
  100.     }
  101. };
  102.  
  103. resource 'hdlg' (HELP_Setup, "Setup Dialog Help", purgeable) {
  104.         HelpMgrVersion,            /* Help version                */
  105.         0,                        /* Offset to first ditl        */
  106.         0,                        /* Options                    */
  107.         0,                        /* The Proc                    */
  108.         0,                        /* Variant                    */
  109.         HMSkipItem { },            /* No missing item strings    */
  110.         {
  111.             HMStringResItem {        /* kOKButton            */
  112.                 { 0, 0 }, { 0, 0, 0, 0 },
  113.                 STRN_SetupHelp, 1,
  114.                 0, 0,
  115.                 0, 0,
  116.                 0, 0
  117.             },
  118.             HMStringResItem {        /* kCancelButton        */
  119.                 { 0, 0 }, { 0, 0, 0, 0 },
  120.                 STRN_SetupHelp, 2,
  121.                 0, 0,
  122.                 0, 0,
  123.                 0, 0
  124.             },
  125.             HMStringResItem {        /* kCalendarUserItem    */
  126.                 { 0, 0 }, { 0, 0, 0, 0 },
  127.                 STRN_SetupHelp, 3,
  128.                 STRN_SetupHelp, 3,
  129.                 STRN_SetupHelp, 3,
  130.                 STRN_SetupHelp, 3,
  131.             },
  132.             HMStringResItem {        /* kFontNamePopupItem    */
  133.                 { 0, 0 }, { 0, 0, 0, 0 },
  134.                 STRN_SetupHelp, 4,
  135.                 STRN_SetupHelp, 4,
  136.                 STRN_SetupHelp, 4,
  137.                 STRN_SetupHelp, 4,
  138.             },
  139.             HMStringResItem {        /* kFontSizePopupItem    */
  140.                 { 0, 0 }, { 0, 0, 0, 0 },
  141.                 STRN_SetupHelp, 5,
  142.                 STRN_SetupHelp, 5,
  143.                 STRN_SetupHelp, 5,
  144.                 STRN_SetupHelp, 5,
  145.             },
  146.             HMStringResItem {        /* kFirstDayPopupItem    */
  147.                 { 0, 0 }, { 0, 0, 0, 0 },
  148.                 STRN_SetupHelp, 6,
  149.                 STRN_SetupHelp, 6,
  150.                 STRN_SetupHelp, 6,
  151.                 STRN_SetupHelp, 6,
  152.             },
  153.             HMSkipItem { },            /* kDayNameUserItem        */
  154.             HMStringResItem {        /* kSundayText            */
  155.                 { 0, 0 }, { 0, 0, 0, 0 },
  156.                 STRN_SetupHelp, 7,
  157.                 STRN_SetupHelp, 7,
  158.                 STRN_SetupHelp, 7,
  159.                 STRN_SetupHelp, 7,
  160.             },
  161.             HMStringResItem {        /* kMondayText            */
  162.                 { 0, 0 }, { 0, 0, 0, 0 },
  163.                 STRN_SetupHelp, 8,
  164.                 STRN_SetupHelp, 8,
  165.                 STRN_SetupHelp, 8,
  166.                 STRN_SetupHelp, 8,
  167.             },
  168.             HMStringResItem {        /* kTuesdayText            */
  169.                 { 0, 0 }, { 0, 0, 0, 0 },
  170.                 STRN_SetupHelp, 9,
  171.                 STRN_SetupHelp, 9,
  172.                 STRN_SetupHelp, 9,
  173.                 STRN_SetupHelp, 9,
  174.             },
  175.             HMStringResItem {        /* kWednesdayText        */
  176.                 { 0, 0 }, { 0, 0, 0, 0 },
  177.                 STRN_SetupHelp,10,
  178.                 STRN_SetupHelp,10,
  179.                 STRN_SetupHelp,10,
  180.                 STRN_SetupHelp,10,
  181.             },
  182.             HMStringResItem {        /* kThursdayText        */
  183.                 { 0, 0 }, { 0, 0, 0, 0 },
  184.                 STRN_SetupHelp,11,
  185.                 STRN_SetupHelp,11,
  186.                 STRN_SetupHelp,11,
  187.                 STRN_SetupHelp,11,
  188.             },
  189.             HMStringResItem {        /* kFridayText            */
  190.                 { 0, 0 }, { 0, 0, 0, 0 },
  191.                 STRN_SetupHelp,12,
  192.                 STRN_SetupHelp,12,
  193.                 STRN_SetupHelp,12,
  194.                 STRN_SetupHelp,12,
  195.             },
  196.             HMStringResItem {        /* kSaturdayText        */
  197.                 { 0, 0 }, { 0, 0, 0, 0 },
  198.                 STRN_SetupHelp,13,
  199.                 STRN_SetupHelp,13,
  200.                 STRN_SetupHelp,13,
  201.                 STRN_SetupHelp,13,
  202.             },
  203.         }
  204. };
  205.  
  206. resource 'STR#' (STRN_SetupHelp, "Setup Dialog Help Strings", purgeable) {
  207.     {    /* [1]    kOKButton                                    */
  208.         "Click this button to update the MacCalendar parameter"
  209.         " resource. Changes take effect after you restart"
  210.         " the computer.",
  211.         /* [2]    kCancelButton                                */
  212.         "Click this button to exit the MacCalendar Setup application"
  213.         " without changing the MacCalendar parameter resource.",
  214.         /* [3] kCalendarUserItem                            */
  215.         "This shows what the calendar will look like after"
  216.         " you click the OK button and restart your computer.",
  217.         /* [4] kFontNamePopupItem                            */
  218.         "This popup menu lets you select the font used to"
  219.         " display the calendar.",
  220.         /* [5] kFontSizePopupItem                            */
  221.         "This popup menu lets you select the font size used"
  222.         " to display the calendar.",
  223.         /* [6] kFirstDayPopupItem                            */
  224.         "This popup menu lets you select the first (leftmost)"
  225.         " day of the week: either Sunday or Monday.",
  226.         /* [7] kSundayText                                    */
  227.         "Sunday: the first day of the week. Derived from late"
  228.         " Latin “dies solis” - day of the sun.",
  229.         /* [8] kMondayText                                    */
  230.         "Monday: the second day of the week. Derived from late"
  231.         " Latin “Lunæ dies” - moon’s day (compare French Lundi).",
  232.         /* [9] kTuesdayText                                    */
  233.         "Tuesday: the third day of the week. Derived from Old"
  234.         " High German “Zîo,” an ancient Teutonic diety, identified"
  235.         " with the Roman Mars; whence “Tíwesdag,” rendering"
  236.         " late Latin “dies Martis” (compare French Mardi).",
  237.         /* [10] kWednesdayText                                */
  238.         "Wednesday: the fourth day of the week. “The day of"
  239.         " (the god) Woden,” a translation of late Latin"
  240.         " “Mercurii dies” whence the name of the day in"
  241.         " the Romance languages.",
  242.         /* [11] kThursdayText                                */
  243.         "Thursday: the fifth day of the week. Derived mainly from"
  244.         " Old Norse “Tórsdagr” ‘day of Thunor or Thor.’ Middle"
  245.         " Germanic Donderday (modern German Donnerstag) derives"
  246.         " from late Latin ”dies Jovis” (compare French Jeudi).",
  247.         /* [12] kFridayText                                    */
  248.         "Friday: the sixth day of the week. Derived from Old"
  249.         " English “Frígedæg” ‘day of (the goddess) Fríg’ from"
  250.         " Old Norse “Frigg” the wife of Odin.",
  251.         /* [13] kSaturdayText                                */
  252.         "Saturday: the seventh day of the week. A half-translated"
  253.         " adoption of Latin “Saturni dies” ‘day of (the planet)"
  254.         " Saturn.’",
  255.     }
  256. };
  257.  
  258. resource 'CNTL' (CNTL_FontPopup, preload, purgeable) {
  259.     kFontPopupRect,                        /* Must match DITL above            */
  260.     popupTitleLeftJust,                    /* Left-justify                        */
  261.     visible,
  262.     41,                                    /* Title width                        */
  263.     MENU_Font,                            /* Font menu                        */
  264.     popupMenuCDEFProc,                    /* It's a popup menu                */
  265.     0,                                    /* refCon, unused                    */
  266.     "Font:"                                /* Title                            */
  267. };
  268.  
  269. resource 'MENU' (MENU_Font, "Font Menu") {
  270.     MENU_Font,
  271.     textMenuProc,
  272.     allEnabled,
  273.     enabled,
  274.     "Font",
  275.     { }
  276. };
  277.  
  278. resource 'CNTL' (CNTL_SizePopup, preload, purgeable) {
  279.     kFontSizePopupRect,                    /* Must match DITL above            */
  280.     popupTitleLeftJust | popupFixedWidth, /* Left-justify                    */
  281.     visible,
  282.     41,                                    /* Title width                        */
  283.     MENU_FontSize,                        /* Font Size menu                    */
  284.     popupMenuCDEFProc,                    /* It's a popup menu                */
  285.     0,                                    /* refCon, unused                    */
  286.     "Size:"                                /* Title                            */
  287. };
  288.  
  289. resource 'MENU' (MENU_FontSize, "Font Size Menu") {
  290.     MENU_FontSize,
  291.     textMenuProc,
  292.     allEnabled,
  293.     enabled,
  294.     "Size",
  295.     {
  296.          "9", noIcon, noKey, noMark, plain,
  297.         "10", noIcon, noKey, noMark, plain,
  298.         "12", noIcon, noKey, noMark, plain,
  299.         "14", noIcon, noKey, noMark, plain,
  300.         "16", noIcon, noKey, noMark, plain,
  301.         "18", noIcon, noKey, noMark, plain,
  302.         "24", noIcon, noKey, noMark, plain,
  303.         "36", noIcon, noKey, noMark, plain,
  304.     }
  305. };
  306.  
  307. resource 'CNTL' (CNTL_FirstDayPopup, preload, purgeable) {
  308.     kFirstDayPopupRect,                    /* Must match DITL above            */
  309.     popupTitleLeftJust,                    /* Left-justify                        */
  310.     visible,
  311.     135,                                /* Title width                        */
  312.     MENU_FirstDay,                        /* Font menu                        */
  313.     popupMenuCDEFProc,                    /* It's a popup menu                */
  314.     0,                                    /* refCon, unused                    */
  315.     "First Day of the Week:"            /* Title                            */
  316. };
  317.  
  318. resource 'MENU' (MENU_FirstDay, "First Day of the Week") {
  319.     MENU_Font,
  320.     textMenuProc,
  321.     allEnabled,
  322.     enabled,
  323.     "Fonts",
  324.     {
  325.         "Sunday", noIcon, noKey, noMark, plain,
  326.         "Monday", noIcon, noKey, noMark, plain,
  327.     }
  328. };
  329.  
  330.  
  331. resource 'MBAR' (MBAR_MenuBar) {
  332.     {
  333.         MENU_Apple,
  334.         MENU_File,
  335.         MENU_Edit
  336.     }
  337. };
  338.  
  339. resource 'MENU' (MENU_Apple, "Apple Menu") {
  340.     MENU_Apple,
  341.     textMenuProc,
  342.     0x7FFFFFFC,
  343.     enabled,
  344.     apple,
  345.     {
  346.         "© 1993 Apple Computer Inc.", noIcon, noKey, noMark, plain,
  347.         "-", noIcon, noKey, noMark, plain
  348.     }
  349. };
  350.  
  351. resource 'MENU' (MENU_File, "File Menu") {
  352.     MENU_File,
  353.     textMenuProc,
  354.     allEnabled,
  355.     enabled,
  356.     "File",
  357.     {    
  358.         "Quit", noIcon, "Q", noMark, plain
  359.     }
  360. };
  361.  
  362. resource 'MENU' (MENU_Edit, "Edit Menu") {
  363.     MENU_Edit,
  364.     textMenuProc,
  365.     0x0,
  366.     enabled,
  367.     "Edit",
  368.     {
  369.         "Undo", noIcon, "Z", noMark, plain,
  370.         "-", noIcon, noKey, noMark, plain,
  371.         "Cut", noIcon, "X", noMark, plain,
  372.         "Copy", noIcon, "C", noMark, plain,
  373.         "Paste", noIcon, "V", noMark, plain,
  374.         "Clear", noIcon, noKey, noMark, plain
  375.     }
  376. };
  377.  
  378. resource 'ALRT' (ALRT_NonFatalError, "Non-fatal Error") {        
  379.     {  85,  85, 260, 400 },
  380.     ALRT_NonFatalError,
  381.     {
  382.         OK, visible, silent,
  383.         OK, visible, silent,
  384.         OK, visible, silent,
  385.         OK, visible, silent,
  386.     },
  387. #if SystemSevenOrLater
  388.         alertPositionMainScreen
  389. #endif
  390. };
  391.  
  392. resource 'DITL' (ALRT_NonFatalError, "Non-fatal Error") {
  393.     {
  394.         { 140, 240, 160, 305 },    Button        { enabled,    "Exit" /* kOKButton */    },
  395.         { 140, 140, 160, 230 },    Button        { enabled,    "Continue"                },
  396.         {  26,  86, 130, 305},    StaticText    { disabled,
  397.             "System Error ^0 (^1): ^2"                                            },
  398.     }
  399. };
  400.  
  401. resource 'ALRT' (ALRT_FatalError, "Fatal Error") {        
  402.     {  85,  85, 260, 400 },
  403.     ALRT_FatalError,
  404.     {
  405.         OK, visible, silent,
  406.         OK, visible, silent,
  407.         OK, visible, silent,
  408.         OK, visible, silent,
  409.     },
  410. #if SystemSevenOrLater
  411.         alertPositionMainScreen
  412. #endif
  413. };
  414.  
  415. resource 'DITL' (ALRT_FatalError, "Fatal Error") {
  416.     {
  417.         { 140, 240, 160, 305 },    Button        { enabled,    "Exit"                    },
  418.         {  26,  86, 130, 305},    StaticText    { disabled,
  419.             "Fatal Error ^0 (^1): ^2"                                            },
  420.     }
  421. };
  422.  
  423. resource 'ALRT' (ALRT_WaitForReboot, "Wait for reboot") {
  424.     {  100, 120, 220, 420 },
  425.     ALRT_WaitForReboot,
  426.     {
  427.         OK, visible, silent,
  428.         OK, visible, silent,
  429.         OK, visible, silent,
  430.         OK, visible, silent,
  431.     },
  432. #if SystemSevenOrLater
  433.         alertPositionMainScreen
  434. #endif
  435. };
  436.  
  437. resource 'DITL' (ALRT_WaitForReboot, "Wait for reboot") {
  438.     {
  439.         {  90, 210, 110, 290 },    Button        { enabled,    "OK" /* kOKButton */    },
  440.         {  90,  10, 110,  90 },    Button        { enabled,    "Cancel"                },
  441.         {   5,  65,  85, 293},    StaticText    { disabled,
  442.                 "Changes take effect\n"
  443.                 "after system restart."
  444.             },
  445.     }
  446. };
  447.  
  448. resource 'ALRT' (ALRT_NoPreferences, "No preference resource or file") {        
  449.     {  85,  85, 280, 480 },
  450.     ALRT_NoPreferences,
  451.     {
  452.         OK, visible, silent,
  453.         OK, visible, silent,
  454.         OK, visible, silent,
  455.         OK, visible, silent,
  456.     },
  457. #if SystemSevenOrLater
  458.         alertPositionMainScreen
  459. #endif
  460. };
  461.  
  462. resource 'DITL' (ALRT_NoPreferences, "No preference resource or file") {
  463.     {
  464.         { 160, 320, 180, 385 },    Button        { enabled,    "Exit"                    },
  465.         {  26,  86, 150, 385},    StaticText    { disabled,
  466.             "Can't find the Control Strip preference file.\n"
  467.             "Please check that the MacCalendar Control Strip has been installed"
  468.             " correctly. If you have just installed it, please restart"
  469.             " your computer and try again."
  470.         },
  471.     }
  472. };
  473.  
  474. resource 'STR#' (STRN_Strings, "Various strings") {
  475.     {
  476.         kCalendarPrefName,                    /* Preference resource name        */
  477.         "Geneva",                            /* Font name                    */
  478.         "9",                                /* Font size                    */
  479.         "1",                                /* 1 == Sunday, 2 == Monday        */
  480.         "\001S\001M\002Tu\001W\002Th\001F\001S\000",    /* Day name string    */
  481.     }
  482. };
  483.  
  484. resource 'STR#' (STRN_Messages, "Various messages") {
  485.     {
  486.         "Reading Preference Resource",
  487.         "Writing Preference Resource",
  488.         "System Error",
  489.     }
  490. };
  491.  
  492. type 'Estr' as 'STR ';
  493. resource 'Estr'    (-23)                { "openErr: Can't open file (permissions)"    };
  494. resource 'Estr'    (-27)                { "abortErr: I/O terminated"                };
  495. resource 'Estr'    (-33)                { "dirFulErr: Disk full: can't write data"    };
  496. resource 'Estr'    (-36)                { "ioErr: General I/O error (bummers)"        };
  497. resource 'Estr'    (-41)                { "mFulErr: Memory full (file won't fit)"    };
  498. resource 'Estr'    (-43)                { "fnfErr: File not found"                    };
  499. resource 'Estr'    (-50)                { "paramErr: Error in user parameter block"    };
  500. resource 'Estr'    (-108)                { "memErr: Out of memory"                    };
  501. resource 'Estr' (-109)                { "nilHandleErr: Unexpected NULL handle"    };
  502. resource 'Estr'    (-192)                { "resNotFound: Missing resource"            };
  503. resource 'Estr'    (-4101)                { "No printer selected in Chooser"            };
  504.  
  505. resource 'SIZE' (-1) {
  506.     reserved,
  507.     acceptSuspendResumeEvents,
  508.     reserved,
  509.     canBackground,
  510.     multiFinderAware,
  511.     backgroundAndForeground,
  512.     dontGetFrontClicks,
  513.     ignoreChildDiedEvents,
  514.     is32BitCompatible,
  515.     notHighLevelEventAware,
  516.     onlyLocalHLEvents,
  517.     notStationeryAware,
  518.     dontUseTextEditServices,
  519.     reserved,
  520.     reserved,
  521.     reserved,
  522.     128 * 1024,
  523.     128 * 1024
  524. };
  525.  
  526. resource 'hfdr' (kHMHelpID) {
  527.     HelpMgrVersion, hmDefaultOptions, 0, 0,
  528.     {
  529.         HMStringItem    {
  530.             "MacCalendarSetup\n\n"
  531.              "Use this application to configure the MacCalendar Control Strip module."
  532.         };
  533.     }
  534. };
  535.  
  536.  
  537. #ifdef __powerc
  538. /*
  539.  * All Power PC applications need a code-fragment resource that the code
  540.  * fragment manager uses to facilitate dynamic fragment binding.
  541.  */
  542. #include "CodeFragmentTypes.r"
  543.     
  544. resource 'cfrg' (0) {
  545.     {
  546.         kPowerPC,
  547.         kFullLib,
  548.         kNoVersionNum,
  549.         kNoVersionNum,
  550.         kDefaultStackSize,
  551.         kNoAppSubFolder,
  552.         kIsApp,
  553.         kOnDiskFlat,
  554.         kZeroOffset,
  555.         kWholeFork,
  556.         "MacCalendar"
  557.     }
  558. };
  559. #endif
  560.